package com.baby.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;

import java.io.IOException;

public class DlxQueueListener implements ChannelAwareMessageListener {


    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        long deliveryTag = message.getMessageProperties().getDeliveryTag();

        try {
            System.out.println("消息："+new String(message.getBody()));
            channel.basicAck(deliveryTag,false);
        } catch (IOException e) {
            channel.basicNack(deliveryTag,false,true);
        }

    }
}
